<?php

/**
 * This is the model class for table "recuperacion".
 *
 * The followings are the available columns in table 'recuperacion':
 * @property integer $id_recuperacion
 * @property integer $id_clase
 * @property string $fecha_clase
 * @property string $motivo
 * @property integer $id_curso
 * @property string $fecha_recuperacion
 * @property string $hora
 *
 * The followings are the available model relations:
 * @property Clase $idClase
 */
class Recuperacion extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Recuperacion the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'recuperacion';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('fecha_clase, fecha_recuperacion, motivo, id_curso, hora', 'required'),
			array('id_clase, id_curso', 'numerical', 'integerOnly'=>true),
			array('fecha_recuperacion', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id_recuperacion, id_clase, fecha_clase, motivo, id_curso, hora, fecha_recuperacion', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'idClase' => array(self::BELONGS_TO, 'Clase', 'id_clase'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id_recuperacion' => 'Id Recuperacion',
			'id_clase' => 'Id Clase',
			'fecha_clase' => 'Fecha Clase',
			'motivo' => 'Motivo',
			'id_curso' => 'Curso',
			'fecha_recuperacion' => 'Fecha Recuperacion',
			'hora' => 'Hora',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id_recuperacion',$this->id_recuperacion);
		//$criteria->compare('id_clase',$this->id_clase);
		$criteria->compare('fecha_clase',$this->fecha_clase,true);
		$criteria->compare('motivo',$this->motivo,true);
		$criteria->compare('id_curso',$this->id_curso);
		$criteria->compare('fecha_recuperacion',$this->fecha_recuperacion,true);
		$criteria->compare('hora',$this->hora,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}